export default {
  setCookie: (cname, cvalue, exdays) => {
    const d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    const expires = `expires=${d.toUTCString()}`;
    document.cookie = `${cname}=${cvalue};path=/;${expires}`;
  },
  // 获取cookie
  getCookie: (cname) => {
    const v = document.cookie.match(`(^|;) ?${cname}=([^;]*)(;|$)`);
    return v ? v[2] : null;
  },
  // 清除cookie
  clearCookie: (cname) => {
    this.setCookie(cname, '', -1);
  },
};
